package com.zhang.network.mapper;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zhang.network.model.User;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zhang.network.model.recommend.RecommendVO;
import org.apache.ibatis.annotations.Select;


/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author zhang
 * @since 2021-04-03
 */
public interface UserMapper extends BaseMapper<User> {

    @Select("select t1.id as primaryKey, t1.reference, t1.friend_id as toId, t1.recommend_rank as recommendRank, " +
            "t1.to_rank as toRank t2.* from recommend t1, user t2 " +
            "where t1.user_id != t1.recommend_id and t1.friend_id = #{userId} and t1.recommend_id=t2.id and t1.status = 1 and t2.status = 1")
    Page<RecommendVO> recommendList(IPage<RecommendVO> page, Integer userId);

    @Select("select t2.*, t1.id as primaryKey, t1.reference, t1.friend_id as toId, t1.recommend_rank as recommendRank, t1.to_rank as toRank from recommend t1, user t2 where " +
            "t1.user_id = t1.recommend_id and t1.friend_id = #{userId} and t1.recommend_id = t2.id and t1.status = 1 and t2.status = 1")
    Page<RecommendVO> friendRequestList(IPage<RecommendVO> page, Integer userId);


    //
//    @Select("select * from t_ ${ew.customSqlSegment}")
//    IPage<Map<String,String>> getList(IPage<Map<String,String>> page, @Param(Constants.WRAPPER) Wrapper wrapper);

}
